package ynu.edu.Entity;

import jakarta.persistence.*;
import lombok.Data;
import lombok.ToString;

import java.util.Date;
import java.util.List;

@Data
@Entity
@Table(name = "greenhouse")
public class Greenhouse {
    @Id
    private Long id;

    private String name;
    private String address;
    private Double area;
    private Date createTime;

    @OneToMany(mappedBy = "greenhouse", cascade = CascadeType.ALL, orphanRemoval = true)
    @ToString.Exclude
    private List<Device> devices;

    @PrePersist
    protected void onCreate() {
        createTime = new Date();
    }
}

